#ifndef MODULE_H_
#define MODULE_H_
#include <config.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <err.h>

#include <sys/types.h>
#include <utmp.h>
#include <paths.h>
#include <syslog.h>

#if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# if HAVE_SYS_TIME_H
#  include <sys/time.h>
# else
#  include <time.h>
# endif
#endif

#ifdef __FreeBSD__
#include <fcntl.h>
#include <kvm.h>
#include <sys/sysctl.h>
#include <sys/user.h>
#include <sys/param.h>
#include <unistd.h>
#endif
#ifdef __linux__
#include <linux/kernel.h>
#include <linux/unistd.h>
#include <sys/sysinfo.h>
#endif
/**
 * \typedef
 * This structure is used to store module specific variables
 */
typedef struct _Core Core;
/**
 * \typedef
 * This structure is used to store Core Config
 */
typedef struct _Core_Config Core_Config;
/**
 * \typedef
 * This structure is used to store widget specific variables
 */
typedef struct _Widget Widget;
/**
 * \typedef
 * This structure is used to store widget configuration
 */
typedef struct _Widget_Config Widget_Config;

struct _Core{
	E_Module *m;
	Core_Config *conf;
   	Evas_List *widgets;
   	E_Config_Dialog *config_dialog;
   	Ecore_Timer *timer;
   	
   	time_t boottime;
    int pagesize;
#ifdef __FreeBSD__
   kvm_t *kd;	
#endif
};

struct _Core_Config{
	int version;
	int poll_time;
	Evas_List *items;
	/*- Default Widget Config -*/
	const char *theme;
	int alpha;
};

struct _Widget{
	E_Module *m;
	Widget_Config *conf;
	E_Gadcon_Client *gcc;
  	Evas_Object *canvas;
  	E_Menu *menu;
	E_Config_Dialog *config_dialog;
};

struct _Widget_Config{
/**
 * Widget Config ID
 */
	const char *id;
/**
 * Widget theme filename
 */
	const char *theme;
/**
 * Widget transparancy
 */
	int alpha;	
};

struct load_average
{
	double la_one; 
	double la_five;
	double la_fifteen;
};


static int _get_nusers();
/**
 * Retrieve system boottime
 */
static time_t _get_boottime();
/**
 * Retrieve system uptime
 */
static	time_t _get_uptime(int boottime);

#ifdef __linux__
/**
 * Retrieve system Load Average
 */
static	struct load_average _get_load_average();

	
#elif defined(__FreeBSD__)
/**
 * Retrieve system Load Average
 */	
static	struct load_average _get_load_average(kvm_t *kd);
	
#endif


#endif /*MODULE_H_*/
